#include <stdio.h>


int main()
{
	struct date{
		int year;
		int month;
		int day;
	}date1;
	scanf("%d",&date1.year);
	scanf("%d",&date1.month);
	scanf("%d",&date1.day);
	int i;
	int day[12]={31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
	int total=0;
	for(i=0;i<date1.month-1;i++)
	{
		total+=day[i];
	}
	if((date1.year%4==0&&date1.year%100!=0)||(date1.year%400==0))
	{
		total+=(1+date1.day);
		printf("%d",total);
	}
	else
	{
		total+=date1.day;
		printf("%d",total);
	}
	return 0;
}